package com.cs.pk.clearcase;

import java.io.IOException;
import java.io.OutputStream;

import com.cs.pk.utils.CmdInputStreamReader;

public class ClearCaseSession {
	
	Process process  = null;
	ProcessBuilder builder = null;
	OutputStream os = null;
	
	private ClearCaseSession SINGLETON = null;
	
	private ClearCaseSession() {
		
	}
	
	private void startCCSession() throws IOException {
		builder = new ProcessBuilder(new String[] { "cmd.exe" });
		process = builder.start();
        
		OutputStream os = process.getOutputStream();
		
		CmdInputStreamReader inputReader = new CmdInputStreamReader(process.getInputStream(),"INPUT",true,false);
		CmdInputStreamReader errorReader = new CmdInputStreamReader(process.getErrorStream(),"ERROR",true,true);
		inputReader.start();
		errorReader.start();
        os.write("@echo off".getBytes());
        os.flush();
	}
	public  String startCCSessions() throws IOException, InterruptedException {
		
		builder = new ProcessBuilder(new String[] { "cmd.exe" });
		process = builder.start();
        
		OutputStream os = process.getOutputStream();
		
		CmdInputStreamReader inputReader = new CmdInputStreamReader(process.getInputStream(),"INPUT",false,true);
		CmdInputStreamReader errorReader = new CmdInputStreamReader(process.getErrorStream(),"ERROR",false,true);
		inputReader.start();
		errorReader.start();
        os.write("@echo off".getBytes());
        os.flush();
        Thread.sleep(100);
        System.out.println("prabhatk: "+inputReader.getResult());
		return null;
		
	}
	
	public static void main(String args[]) throws IOException, InterruptedException {
		//startCCSession();
	}
	

}
